# -*- coding:utf-8 -*-
"""
@Author : 审心
@Time : 2023/4/28 16:20
"""
import time

from DrissionPage import WebPage

from common.utils.web_page_util import wait_ele_disappear


def wait_tb_complete(page: WebPage, open_error: bool = True, delay: int = 3, loading_time: int = 20) -> object:
    """
    等待表格加载完毕
    :param open_error: 是否开启抛出异常
    :param page: 网页对象
    :param delay: 延迟 默认3秒
    :param loading_time: 等待元素时长
    """
    if not wait_ele_disappear(page, ".oui-dt-message-content oui-dt-message-content-hasMask",
                              timeout=loading_time) and open_error:
        raise RuntimeError("等待表格加载数据失败")
    time.sleep(delay)
